CALL apoc.load.json("file:///persons.json")
YIELD value as data
MERGE (p:Person {name: data.姓名})
SET p.description = data.姓名,
    p.alias = data.别号,
    p.position = data.职位,
    p.des = data.描述,
    p.items = reduce(s = '', item in keys(data.拥有物品) | s + item + ': ' + data.拥有物品[item] + '; ')
WITH p, data
UNWIND data.相关事件 AS event
MERGE (e:Event {name: event})
MERGE (p)-[:participate_events]->(e)
MERGE (e)-[:related_person]->(p)
WITH p, data
FOREACH (relation in keys(data.人际关系) | 
    FOREACH (relatedPerson in COALESCE(data.人际关系[relation], [data.人际关系[relation]]) | 
        MERGE (rp:Person {name: relatedPerson})
        MERGE (p)-[:relation {type: relation}]->(rp)))

CALL apoc.load.json("file:///places.json")
YIELD value as data
MERGE (p:Place {name: data.名称})
SET p.description = data.名称,
    p.location = data.所在位置,
    p.des = data.描述
WITH p, data
UNWIND data.发生事件 AS event
MERGE (e:Event {name: event})
MERGE (p)-[:event_occurred]->(e)
MERGE (e)-[:occurred_on]->(p)

call apoc.load.json("file:///houses.json")
yield value as data
merge (h:House {name: data.名称})
set h.description = data.名称,
    h.des = data.描述
with h, data
unwind data.包含人物 as person
merge (p:Person {name: person})
merge (p)-[:owner_house]->(h)
merge (h)-[:owned_person]->(p)

call apoc.load.json("file:///events.json")
yield value as data
merge (e:Event {name: data.简述})
set e.description = data.简述,
    e.des = data.具体过程,
    e.time = data.发生时间
with e, data
unwind data.参与者 as person
merge (per:Person {name: person})
merge (per)-[:participate_events]->(e)
merge (e)-[:related_person]->(per)
with e, data
unwind data.发生地点 as place
merge (pla:Place {name: place})
merge (pla)-[:event_occurred]->(e)
merge (e)-[:occurred_on]->(pla)